package com.dd.common.dto.system.file.folder;

import com.dd.common.pojo.dto.group.CreateGroup;
import com.dd.common.pojo.dto.group.UpdateGroup;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.*;

/**
 * @author cheng
 */
@Schema(description = "文件管理文件夹DTO，包括crate和update")
@Data
public class SysFileFolderDTO implements java.io.Serializable {

    @Null(message = "ID必须为空", groups = CreateGroup.class)
    @NotNull(message = "ID不能为空", groups = UpdateGroup.class)
    @Schema(description = "文件夹ID", example = "1")
    @Min(value = 1, message = "ID必须是正整数")
    private Long id;

    @Schema(description = "父文件夹ID", example = "1")
    @Min(value = 1, message = "ID必须是正整数")
    private Long parentId;

    @NotBlank(message = "文件夹名称不能为空", groups = CreateGroup.class)
    @Schema(description = "文件夹名称", example = "用户头像")
    private String folderName;

    @NotBlank(message = "文件夹标识符不能为空", groups = CreateGroup.class)
    @Pattern(regexp = "^[a-zA-Z_][a-zA-Z0-9_]*$", message = "文件夹标识符只能包含字母、数字、下划线，且不能以数字开头")
    @Schema(description = "文件夹标识符", example = "avatar")
    private String folderKey;

    @Schema(description = "排序", example = "1")
    @Min(value = 1, message = "排序值必须是正整数")
    private Integer sort;

    @Schema(description = "状态（1-正常，0-禁用）", example = "1")
    @Range(min = 0, max = 1, message = "状态值只能是0或1")
    private Integer status;
}
